import { defineStore } from 'pinia'

export const useHomeStore = defineStore(
  'homeStore',
  () => {
    const total = ref<number>(0)
    const add = () => {
      total.value = total.value + 1
    }
    const minus = () => {
      if (total.value === 0) {
        return
      }
      total.value = total.value - 1
    }
    return {
      total,
      add,
      minus
    }
  },
  {
    persist: [
      {
        key: 'homeStore',
        storage: localStorage,
        pick: ['total']
      }
    ]
  }
)
